//
//  MapCell.m
//  Belt
//
//  Created by nsm on 2017/12/21.
//  Copyright © 2017年 beisheng. All rights reserved.
//

#import "MapCell.h"
#import "AMapHelper.h"

@interface MapCell () {
    UILabel *_titleLabel;
    UILabel *_subTitleLabel;
}
@end

@implementation MapCell

- (void)setObject:(AMapPOI *)poi {
    _titleLabel.attributedText = AttributedString(FormatString(@"%@ · ",SafeString(poi.name)),
                                                  BoldSystemFont(15),
                                                  COLOR_1,
                                                  FormatString(@"%@米",@(poi.distance)),
                                                  BoldSystemFont(15),
                                                  COLOR_0,
                                                  NSTextAlignmentLeft,
                                                  0);
    _subTitleLabel.text = poi.address.length? poi.address: @"-";
}

- (void)setupSubviews {
    self.backgroundColor = COLOR_4;
    self.contentView.backgroundColor = COLOR_4;
    
    MyLinearLayout *layout = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert];
    layout.myHorzMargin = 0;
    layout.cacheEstimatedRect = YES;
    layout.gravity = MyGravity_Horz_Fill;
    layout.padding = UIEdgeInsetsMake(12, 15, 12, 15);
    layout.subviewVSpace = 2;
    [self.contentView addSubview:layout];
    self.rootLayout = layout;
    
    _titleLabel = [UILabel new];
    _titleLabel.wrapContentHeight = YES;
    _titleLabel.numberOfLines = 2;
    [layout addSubview:_titleLabel];
    
    _subTitleLabel = [UILabel new];
    _subTitleLabel.font = CustomFont(13);
    _subTitleLabel.textColor = COLOR_3;
    _subTitleLabel.wrapContentHeight = YES;
    _subTitleLabel.numberOfLines = 2;
    [layout addSubview:_subTitleLabel];
}

@end
